import React, { CSSProperties } from "react";
import * as amis from 'amis';
import * as amisEditor from 'amis-editor';
import * as udpUI from '@cscec/udp-ui';
import ReactDOM from 'react-dom';
import * as antd from 'antd';

/**
 * amis项目传入的外部包
 */
export interface IPackages {
  amis: typeof amis;
  amisEditor: typeof amisEditor;
  udpUI: typeof udpUI;
  React: typeof React;
  ReactDOM: typeof ReactDOM;
  antd: typeof antd;
  [x: string]: any;
}

/**
 * amis组件及相关配置信息
 */
export interface IComponentConfig<ComponentProps = any> {
  pluginName?: string;
  component: React.FC<ComponentProps>;
  options: {
    // 组件分组
    group?: string;
    // 组件类型，唯一
    type: string;
    // 组件名称
    name: string;
    // 组件图标
    icon?: string;
    // 组件描述
    description: string;
    // 属性面板标题
    panelTitle?: string;
    // 设置默认值
    scaffold?: Partial<ComponentProps>;
    // 属性定义
    panelTabs?: Array<{ title: string, body: Array<Record<string, any>> }>;
  };
}

/**
 * 用于生成amis组件及相关配置信息
 */
export type ComponentGenerator<ComponentProps = any> = (packages: IPackages) => IComponentConfig<ComponentProps>;

/**
 * amis编辑器组件插件
 */
export interface IAmisEditorPlugin {
    name: string;
    type: string;
    plugin: any;
}

/**
 * 自定义表单项默认支持的配置项属性
 */
export interface IBaseFormItemProps {
    name: string;
    style?: CSSProperties;
    label?: string;
    disabled?: boolean;
    hidden?: boolean;
    [x: string]: any;
}
